/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package factory;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.state.StateBasedGame;

/**
 *
 * @author wida46984148
 */
public class shootI extends Shoot {

    Image image;

    public shootI(float dany, Image image) {
        super(dany);
        this.image = image;

    }

    /**
     * Canvia la posicio del projectil
     * @param posX
     * @param posY
     */
    @Override
    public void setLocation(float posX, float posY) {
        super.setLocation(posX, posY);
        super.shape = new Rectangle(posX, posY, image.getWidth(), image.getHeight());
    }

    /**
     * Rederitza el projectil
     * @param gc
     * @param g
     */
    @Override
    public void render(GameContainer gc, Graphics g) {
        g.drawImage(image, posX, posY);
    }

    /**
     * Copia el projectil
     * @return projectil clonat
     */
    @Override
    public Shoot copiarShoot() {
        return new shootI(dany, image);
    }

    /**
     * Getter projectil clonat
     * @return projectil
     */
    public Shoot cloneShoot() {
        Shoot p = (Shoot) copiarShoot();
        p.setLocation(posX, posY);
        return p;
    }

    /**
     * Genera impacte
     */
    public void impacte() {
        this.destroy = true;
    }

    @Override
    public void update(GameContainer gc, StateBasedGame sb, int delta) {
                System.out.println("hola estoy en el update");
    }

    public Image getImage() {
        return image;
    }

    @Override
    public void update(int delta) {
        if (!destroy) {
            if (posY <= -10) {
//                posY = -11;
//                posX = 1000;
            } else {
                posX -= 7;
                posY += 13;

                shape.setLocation(posX, posY);
            }
        } else {
            posY = 1300;
            posX = 1300;
        }
    }

    @Override
    public String toString() {
        return "hola soy un disparo malote";
    }
}


